package com.foreverwin.jzymes.eap.Listener;

import com.foreverwin.jzymes.common.domain.EapLog;
import com.foreverwin.jzymes.common.service.IEapLogService;
import com.foreverwin.jzymes.framework.util.ObjectMapperUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

@Component
public class EapLogListener {

    @Autowired
    IEapLogService eapLogService;

    @JmsListener( destination = "MES_EAP_LOG" )
    public void saveEapLog( String eapLogJson ){
        EapLog eapLog = null;
        try {
            eapLog = ObjectMapperUtil.readValue( eapLogJson, EapLog.class );
            eapLogService.insertEapLog( eapLog );
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
